/**
 * Copyright 2011 Joe Choi, All rights reserved.
 */
package tec.config.xml;

import java.io.FileOutputStream;

import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Text;



/**
 * @author Joe Choi
 */
public class XmlWriter {
	public static void main(String[] args) throws Exception {
		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
		Document doc = factory.newDocumentBuilder().newDocument();
		Transformer tf = TransformerFactory.newInstance().newTransformer();
		
		Element root = doc.createElement("Configuration");
		Element dataSource = doc.createElement("Sqlite");
		Element driverName = doc.createElement("DriverName");
		Text dn = doc.createTextNode("java.sql.sqlite");
		
		doc.appendChild(root);
		root.appendChild(dataSource);
		dataSource.appendChild(driverName);
		driverName.appendChild(dn);
		
		tf.transform(new DOMSource(doc), new StreamResult(new FileOutputStream("xml.conf")));
	}	
}
